package cn.virens.common.oauth.service;

import cn.virens.common.oauth.request.principal.DelegatePrincipal;
import cn.virens.common.oauth.request.principal.DelegatePrincipalResult;
import cn.virens.common.util.exception.APIException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.util.Optional;

public interface AuthenticationServiceBase {
    /**
     * 执行用户登录：构建相关缓存
     */
    <T extends DelegatePrincipalResult> T login(HttpServletRequest request, HttpServletResponse response, T result) throws APIException;

    /**
     * 根据令牌：清理登录信息
     */
    <T extends DelegatePrincipal> T logout(HttpServletRequest request, HttpServletResponse response, T principal) throws APIException;

    /**
     * 根据网络请求获取对应的登录令牌
     */
    Optional<DelegatePrincipal> authorization(HttpServletRequest request) throws APIException;

}
